package Lee_code;

public class Lee_516 {
    int res=0;
    public int longestPalindromeSubseq(String s) {
        int len = s.length();
        char[] in = new char[len];
        in = s.toCharArray();
        for(int i=0; i<len; i++)
        {
            judge(i, i, in);
            if (i+1<len)
                judge(i, i+1, in);
        }
        return res;
    }

    private void judge(int left, int right, char[] in) {
        while (left>=0 && right<=in.length-1){
            if (in[left] == in[right]){
                res = Math.max(res, right-left+1);
                left--;
                right++;
            }
            else
                return;
        }
    }
}
